package com.pro.service.imple;

import com.pro.mapper.JsLoginUserMapper;
import com.pro.pojo.JsUser;
import com.pro.service.JsLoginUserService;
import com.pro.utils.MD5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClassName:JsLoginUserServiceImple
 * Package:com.pro.service.imple
 * Description:
 *
 * @Date:2022/1/7 19:47
 * @Author: XJR
 */
@Service
public class JsLoginUserServiceImple implements JsLoginUserService {

    @Autowired
    private JsLoginUserMapper mapper;

    //登录
    public JsUser loginUser(String account, String password){
        JsUser jsUser = mapper.loginUser(account, password);
        return jsUser;
    };

    //根据名字查询
    public JsUser loginByName(String username){
        JsUser jsUser = mapper.loginByName(username);
        return jsUser;
    };

    @Override
    public List<JsUser> getLoginMsg(String account) {
        List<JsUser> loginMsg = mapper.getLoginMsg(account);
        return loginMsg;
    }
    /**
     *
     * @author ZPT
     * @date 2022/1/16 16:26
     * @content :根据用户id查询信息
     */
    public JsUser getUserById(Integer userId){
        return mapper.getUserById(userId);
    }
    /**
     *
     * @author ZPT
     * @date 2022/1/16 16:36
     * @content :修改密码，头像
     */
    public Boolean updateUser(Integer userId,String password,String acatarUrl){
        if (password!=null){
            password = MD5Util.md5(password);
        }
        return mapper.updateUser(userId,password,acatarUrl);
    }
}
